package com.zhen.mapper;

import com.zhen.domain.Clazz;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

public interface ClazzMapper {

    @Select("SELECT * FROM tb_clazz WHERE id = #{id}")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "code",property = "code"),
            @Result(column = "name",property = "name"),
            @Result(column = "id",property = "students",
            many = @Many(
                    select = "com.zhen.mapper.StudentMapper.selectByClazzId",
                    fetchType = FetchType.LAZY
            )),
    })
    Clazz selectById(Integer id);

}
